<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增辈分')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-seniority-add">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required"> 所属家族：</label>
                <div class="col-sm-8">
                    <select class="form-control" id="surnameId" name="surnameId" onchange="surnameIdChangeFun()"  required>
                        <option value="">请选择</option>
                        <option th:each="dict : ${fcanList}" th:text="${dict.name}" th:value="${dict.cId}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">辈序号：</label>
                <div class="col-sm-8">
                    <input id="numSort" name="numSort" class="form-control" type="text" style="width: 60%;float: left;" required>
                    <label class="col-sm-3 control-label" style="width: 40%;float: left;text-align: left;">(智能填写可调整)</label>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">辈名称：</label>
                <div class="col-sm-8">
                    <input name="numTag" class="form-control" type="text" style="width: 60%;float: left;" required>
                    <label class="col-sm-3 control-label" style="width: 40%;float: left;text-align: left;">(辈名称要与辈序号对应)</label>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">行辈字：</label>
                <div class="col-sm-8">
                    <input name="cnTag" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="remark" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group" style="display: none;">
                <label class="col-sm-3 control-label">删除标志：</label>
                <div class="col-sm-8">
                    <input name="delFlag" class="form-control" value="0" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "family/seniority"
        $("#form-seniority-add").validate({
            focusCleanup: true
        });

        //家族下拉列表改变触发
        function surnameIdChangeFun()
        {
            var surnameIdVal = $("#surnameId").val();
            console.log("列表改变的值：" + surnameIdVal);
            $.ajax({
                url: prefix + "/getMaxNumSort",
                type: 'GET',
                data: {
                    surnameId: surnameIdVal
                },
                success: function (data) {
                    console.log("data.code:" + data.code);
                    if(data.code == 0){
                        console.log("data.maxNumSort:" + data.maxNumSort);
                        $("#numSort").val(data.maxNumSort);
                    }
                }
            });
        }

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-seniority-add').serialize());
            }
        }

    </script>
</body>
</html>